﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace dpruna.SharePoint
{
    public partial class ExtendedLookupCustomProperties : UserControl
    {
        const string DefaultSearchPageURL = "/_layouts/ExtendedLookup/LookupPage.aspx";

        public void InitializeWithField(ExtendedLookup lookupField, string allowMultiValClientId, bool bTargetListChanged)
        {
            if (!this.Page.IsPostBack)
            {
                if (lookupField == null)
                    this.SearchPageURLTextBox.Text = DefaultSearchPageURL;
                else
                    this.SearchPageURLTextBox.Text = lookupField.SearchPageURL;
            }
        }

        internal void OnSaveChange(ExtendedLookup lookupField)
        {
            lookupField.UpdateFieldCustomProperty(ExtendedLookup.CP_SearchPageURL, this.SearchPageURLTextBox.Text);
        }
    }
}
